dxl layout global int

I'm trying to keep count of specified objects within a layout DXL.  Obviously the script below will have count_ER reset for each object and display '1' for every object that meets the specified criteria instead of maintaining a count.  Is there some sort of buffer equivalent I can use for maintaining a count in a layout DXL? 

int count_ER = 0

if (probeAttr_(obj,TYPE) == "Emergency") {
count_ER++
display count_ER""
}


stevenson - Mon Sep 09 19:06:36 EDT 2013

Re: dxl layout global int
adevicq - Tue Sep 10 03:20:29 EDT 2013

Hi,

You can store the temporary value in a module attribute...

I don't see any other way.

Alain

Re: dxl layout global int
Mike.Scharnow - Tue Sep 10 03:37:25 EDT 2013

you could use a top level variable (see e.g. https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014832013#77777777-0000-0000-0000-000014832702)

 

But I'm not sure at what time you will want to initialize or re-initialize the variable.

Perhaps you're better off with a small script that just counts all Emergency objects in the current view and that is started as a pull down menu.

Re: dxl layout global int
llandale - Tue Sep 10 13:22:03 EDT 2013

You want a column that shows the total number of Emergency objects in the module; same value displayed for all objects?  That seems a bit out of context for a "Layout" or "Attr-DXL".

You could do it easily with an Attr-DXL instead of a layout:

  • for o in entire m do
  • {  if (isDeleted(o)) continue
  •     if is Emergency then Count++
  • }
  • for o in entire m do
  • {  o.attrDXLName = Count""
  • }

-Louie

Re: dxl layout global int
stevenson - Tue Sep 10 17:05:11 EDT 2013

llandale - Tue Sep 10 13:22:03 EDT 2013

You want a column that shows the total number of Emergency objects in the module; same value displayed for all objects?  That seems a bit out of context for a "Layout" or "Attr-DXL".

You could do it easily with an Attr-DXL instead of a layout:

  • for o in entire m do
  • {  if (isDeleted(o)) continue
  •     if is Emergency then Count++
  • }
  • for o in entire m do
  • {  o.attrDXLName = Count""
  • }

-Louie

Thanks.  I changed it from layout DXL to a DXL attribute and I ended up using a variation of this: 

Object oAll= current
Module m = current
int iThisAbsNum = obj."Absolute Number"
int iAbsNum
int iCountEmergency= 1

string Emergency

int iOffset, iLength

for oAll in m do {
 Emergency = oAll ."Emergency"
 iAbsNum= oAll."Absolute Number"

 if(findPlainText (Emergency, "Fire", iOffset, iLength, false)) {
  if(iAbsNum == iThisAbsNum) displayRich("\\pard " iCountEmergency "")
  else iCountEmergency++
 }

}

It was necessary to compare the absolute number of the object so it only wrote to the correct object.  Otherwise it was reading the same number in each field since the count was being reset everytime and using the initial count value for the object value.  Also, I used the findPlainText to identify the text within the Emergency field since it sometimes contained unintended spaces.  Otherwise I would've had to change all my Emergency types to an enumeration.